const Mock = require('mockjs');

// 任务查询响应数据
const taskListResponse = {
  "total": 1,
  "rows": [
    {
      "id": 1,
      "dataSetId": null,
      "taskName": "测试",
      "testType": null,
      "errorStrategy": null,
      "triggerRule": null,
      "startTime": null,
      "endTime": null,
      "cron": null,
      "endStrategy": null,
      "deviceType": null,
      "duration": null,
      "sendFlag": null,
      "localLongitude": null,
      "localLatitude": null,
      "localAltitude": null,
      "remoteLongitude": null,
      "remoteLatitude": null,
      "remoteAltitude": null,
      "localPitchAngle": null,
      "localCurrentPitchAngle": null,
      "scatteringDeviceType": null,
      "waveType": null,
      "channel": null,
      "sendPower": null,
      "freqType": null,
      "freq": null,
      "stopFreq": null,
      "highFreq": null,
      "stopHighFreq": null,
      "freqInterval": null,
      "jumpTableNum": null,
      "iqCollectFlag": null,
      "iqBusinessData": null,
      "iqCollectInterval": null,
      "dataSetName": ""
    }
  ],
  "code": 200,
  "msg": "成功"
};

// 任务删除响应数据
const taskDeleteResponse = Mock.mock({
  "msg": "成功",
  "code": 200
});

// 任务同步响应数据
const taskSyncResponse = Mock.mock({
  "msg": "成功",
  "code": 200
});

// 任务更新响应数据
const taskUpdateResponse = Mock.mock({
  "msg": "成功",
  "code": 200
});

// 修改导出方式
module.exports = [
  {
    url: '/task/list',
    method: 'get',
    response: (config) => {
      return taskListResponse;
    }
  },
  {
    url: '/taskDelete',
    method: 'post',
    response: (config) => {
      return taskDeleteResponse;
    }
  },
  {
    url: '/task/sync/trigger',
    method: 'post',
    response: (config) => {
      return taskSyncResponse;
    }
  },
  {
    url: '/taskUpdate',
    method: 'post',
    response: (config) => {
      if (config.body) {
        return taskUpdateResponse;
      } else {
        return {
          "msg": "请求体不能为空",
          "code": 400
        };
      }
    }
  }
];